<template></template>
<script setup>
// 先拿到用户的id  然后通过用户的id再拿到用户的信息
let idPromise = new Promise((resolve, reject) => {
  setTimeout(() => {
    reject(1);
  }, 1000);
});

let listPromise = (id) => {
  return new Promise((resolve, reject) => {
    console.log("拿到id了", id);
    setTimeout(() => {
      resolve({ name: "小明", job: "前端开发" });
    }, 1000);
  });
};

idPromise
  .then(
    (result) => {
      return listPromise(result);
    }
    // (errorMsg) => console.log("请求用户Id时，发生错误", errorMsg)
  )
  .then((result) => console.log("第二个then，返回的用户数据", result))
  .catch((errorMsg) => {
    console.log("通用错误处理", errorMsg);
  })
  .finally(() => {
    console.log("finally执行了");
  });

// const test = () => {
//   return new Promise(() => {});
// };

// console.log(test());
</script>
<style></style>
